#include "../logs/log.hpp"
#include <unistd.h>

//全局建造者测试函数
void test_Globbal(const std::string &name)
{
    INFO("%s", "测试日志器");

    wu::Logger::ptr logger = wu::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s", "测试日志器");
    logger->info("%s", "测试日志器");
    logger->warn("%s", "测试日志器");
    logger->error("%s", "测试日志器");
    logger->fatal("%s", "测试日志器");
    // int n = 500000;
    // while(n--)//五十万条数据
    // {
    //     logger->fatal("%s-%d", "测试日志器", n);
    // }

    INFO("%s", "测试日志器");
}

int main()
{
    std::string name = "async-logger";
    std::unique_ptr<wu::LoggerBuilder> build(new wu::GlobalLoggerBuilder());
    build->buildLoggerName(name);
    build->buildLoggerType(wu::LoggerType::LOGGER_SYNC);
    build->buildFormatter("[%c][%f:%l][%p]%m%n");
    build->buildLoggerLevel(wu::LogLevel::value::DEBUG);
    build->buildSink<wu::StdoutSink>();
    build->buildSink<wu::FileSink>("./filelog/async.log");
    build->build();
    test_Globbal(name);

    return 0;
}